<?php
	require_once("../classes/EntryList.php");
	require_once("../classes/Database.php");
	
	session_start();
	
	$find = "%".$_POST["find"]."%";
	
	$db = new Database("localhost", "root", "");
	$db->connect("emprego");
	$db->executeQuery("SELECT id, nome, email FROM users WHERE nome LIKE '$find' AND roles LIKE '%candidate%'");
	
	$entry = new EntryList("entry");
	while($line = $db->getResultLine(MYSQL_ASSOC)){
		$entry->openEntry();
		$entry->addLinkTitle("viewCV.php?candidate=".$line["id"], "Ver Curriculum");
		$entry->addEntry("Nome:", $line["nome"]);
		$entry->addEntry("E-mail:", $line["email"]);
		$entry->closeEntry();
		$entry->addHtmlCode("</br></br>");
	}
	
	$_SESSION["entry"] = $entry;
	header("Location: ../findCandidate.php");
?>